#ifndef QQ_SQL
#define QQ_SQL

#include <qapplication.h>
#include <qobject.h>
#include <qstring.h>

#include <QxOrm.h>

#include "core/QQConfig.h"

#define qq_sql QQSql::get_instance()

class QQSql : public QObject
{
	Q_OBJECT

private:
	QQSql(QObject* parent = nullptr);
	~QQSql();
public:
	static QQSql* get_instance();
	void init();
	QQFriend get_friend_info_by_account(const QString& account);
	QList<QQFriend> get_friend_list();
	QString get_friend_icon_by_account(const QString& account);
	QString get_friend_nickname_by_account(const QString& account);
	void add_friend(QQFriend& friend_info);
	void delete_friend(const QString& account);
	QQMessage get_message_info_by_id(long id);
	QList<QQMessage> get_message_list_by_sender(const QString& sender);
	QList<QQMessage> get_message_list_by_receiver(const QString& receiver);
	QList<QQMessage> get_message_list_by_sender_and_receiver(const QString& sender, const QString& receiver);
	void add_message(QQMessage& message_info);
	void delete_message(long id);
};

QX_REGISTER_HPP(QQFriend, qx::trait::no_base_class_defined, 0)
QX_REGISTER_HPP(QQMessage, qx::trait::no_base_class_defined, 0)

#endif